<?php

//echo br(3); ###########################################################################################

	$TEMP->set_file(array('handle' => DIR_VIEW_DEAN . 'timeSchedules.html'));
	
	
	if ( isset($_POST['subButton']) ) {
		$if_error	= 0;
		$txtroom	= _POST('txtroom');
		$txtlab		= _POST('txtlab');
		if ( empty($txtroom) )	{ $if_error++; $_txtroom 	= REQ_FIELD; }
		if ( $if_error == 0 ) {
			$strArray = array('room' => upperCase($txtroom), 'lab_lec' => $txtlab, 'dept_id' => $strAccDept);
			$DSC->insertDeptRooms($strArray);
			redirect('?page=DepartmentRooms');
		}
	}
	
	$roomsDepartment = $DSC->getRoomsDepartment($strAccDept);

	
	# LSITING
	if ( !empty($roomsDepartment) ) {
		
		$TEMP->set_block('handle',  'rooms', 'roomsRow');
		$bgcolor 	= LOOPING_F0F;
		$numCount 	= 1;
			
		foreach($roomsDepartment as $roomsDepartmentValue) {
			
			$edButton = '<div class="icon-button">
								<img src="' . DIR_IMAGES . 'icon/recyclebin.png" title="Delete" border="0" onclick="popupDelete(\'' . $roomsDepartmentValue['room_idPK'] . '\', \'260\');"/>
								<div class="delete-button" id="delete_button_' . $roomsDepartmentValue['room_idPK'] . '">
									<div class="delete-label">Delete this room?</div>
									<div class="delete-yes-no" onclick="deleteRooms(\'' . $roomsDepartmentValue['room_idPK'] . '\');">Yes</div>
									<div class="delete-yes-no" onclick="popupDeleteHide(\'' . $roomsDepartmentValue['room_idPK'] . '\');">No</div>
								</div>
							</div>';
							
			$TEMP->set_var(array('room' 		=> $roomsDepartmentValue['room_desc'],
								 'type' 		=> ($roomsDepartmentValue['room_type'] == 1) ? 'Laboratory Room':'Lecture Room',
								 'room_id' 		=> $roomsDepartmentValue['room_idPK'],
								 'numbering'	=> $numCount,
								 'bgcolor'		=> $bgcolor,
								 'ed_button'	=> $edButton
								));
								
			$TEMP->parse('roomsRow', 'rooms', true);
			$bgcolor = ($bgcolor == LOOPING_F0F) ? LOOPING_FFF : LOOPING_F0F;
			$numCount++;
		}
	}
	else {
		$TEMP->set_var(array('room' 		=> '',
							 'room_id' 		=> '',
							 'numbering'	=> '',
							 'bgcolor'		=> '',
							 'ed_button'	=> '',
							));
	}
	
	$TEMP->set_var(array('dean_sub_menu'	=> $pageLib->deanSubMenu(DIR_IMAGES),
						 'dept_course'		=> $strAccCourse,
						 'w_txtroom' 		=> $_txtroom,
						));
?>